Skip to content

Accept score answers with surrounding whitespace - #97

Merged
dmccoystephenson merged 1 commit into
mainfrom
feat/trim-score-answers
Nov 15, 2026
Merged

dmccoystephenson merged 1 commit into
mainfrom
feat/trim-score-answers

Conversation

@dmccoystephenson

Copy link
Copy Markdown
Member

Summary

  • Interactive create score answers are now trimmed before Integer.parseInt in CreateProjectCommand.getAverageScore, so an answer such as 4 or 4 is accepted instead of being rejected with Invalid score. Must be a number between 1 and 5. and re-asking the whole category. This matches how quit tokens already tolerate surrounding whitespace.
  • testScoreAnswerWithSurroundingWhitespaceIsAccepted was added to CreateProjectCommandTest. Each padded answer is stubbed to be followed by q, so a regression fails the assertion cleanly instead of re-asking forever (an earlier stub without the q follow-up made the test executor crash when the fix was reverted).
  • The README's interactive-scoring bullet now states that spaces before or after an answer are ignored.

Closes #95

Test plan

  • ./gradlew test on JDK 21: 195 tests executed, 0 failures, 0 errors (counted from build/test-results/test/*.xml)
  • Fix reverted with git stash: the new test fails with AssertionFailedError; fix restored: it passes

Skipped issues

This PR description was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).

🤖 Generated with Claude Code


drafted by Claude on behalf of Daniel Stephenson

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Test Results

195 tests  +1   195 ✅ +1   2s ⏱️ ±0s
 25 suites ±0     0 💤 ±0 
 25 files   ±0     0 ❌ ±0 

Results for commit adf06af. ± Comparison against base commit 494558f.

@dmccoystephenson

Copy link
Copy Markdown
Member Author

Self-review rubric (head adf06af):

  • Scope: PASS — three files changed: the one-line trim in CreateProjectCommand.getAverageScore, one new test, one README bullet; all serve Interactive score answers with surrounding spaces are rejected as non-numbers #95.
  • Tests-new: PASS — no new public method; the changed private path is exercised by testScoreAnswerWithSurroundingWhitespaceIsAccepted.
  • Tests-fix: PASS — with the fix stashed, CreateProjectCommandTest ran 17 tests with 1 failure (AssertionFailedError at line 335, the new test); with it restored, the full suite passed. The first version of the test re-asked forever when the fix was reverted and crashed the Gradle test executor, so the stub was changed to follow each padded answer with q. A regression now fails as a clean assertion.
  • Sibling structure: PASS — the test follows the stubbing, captureStandardOutput and verify(..., times(1)) pattern of testNonNumericAnswerReprompts and testOutOfRangeAnswerRepromptsTheWholeCategory.
  • Sibling renames: PASS — nothing renamed.
  • Docs: PASS — README interactive-scoring bullet updated; CONTRIBUTING.md's ./gradlew test is unchanged and still correct.
  • Issue resolution: PASS — Interactive score answers with surrounding spaces are rejected as non-numbers #95's suggested fix (trim before Integer.parseInt) and its suggested padded-score test case are both present.
  • Manual validation: PASS — local ./gradlew test on JDK 21 ran 195 tests with 0 failures; CI build (21), test and Test Results are green on the PR head.
  • Shell command tests: PASS — CreateProjectCommandTest covers the changed @ShellMethod path.
  • Round-trip coverage: N/A — no domain fields added.
  • I/O behind an interface: N/A — no new I/O.

Notes:

  • README.md:81 — String.trim() strips tabs as well as spaces (the test includes a 3\t answer), while the README only mentions spaces. This is left as is because spaces are the case a user is likely to hit.
  • src/main/java/com/preponderous/parpt/command/CreateProjectCommand.java:46 — the existing comment in readInput ("the answer itself is returned untouched") still holds, because trimming happens in the caller and only for score answers. Name and description answers are still stored without trimming.

No paths on the do-not-auto-merge list are modified. The PR is considered ready to merge.

This review was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).


drafted by Claude on behalf of Daniel Stephenson

@dmccoystephenson
dmccoystephenson merged commit 1331d1c into main Nov 15, 2026
3 checks passed
@dmccoystephenson
dmccoystephenson deleted the feat/trim-score-answers branch November 15, 2026 03:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Interactive score answers with surrounding spaces are rejected as non-numbers

1 participant